package com.casework

import grails.plugin.spock.TagLibSpec
import spock.lang.Unroll


class SearchTagLibSpec extends TagLibSpec {

    @Unroll('When searching for #textQuery should have #expectedOutput')
    def "search text is highlighted"() {
        given:
        mockParams.textQuery = textQuery

        when:
        def out = highlight(name: 'hello') {bodyText}

        then:
        out == expectedOutput

        where:
        bodyText                     | textQuery   | expectedOutput
        ""                           | ""          | ""
        ""                           | "search"    | ""
        "nothing"                    | "search"    | "nothing"
        "something"                  | "something" | "<strong>something</strong>"
        "something"                  | "SOMETHING" | "<strong>something</strong>"
        "I like some good dark beer" | "beer good" | "I like some <strong>good</strong> dark <strong>beer</strong>"
        "beer beer"                  | "beer good" | "<strong>beer</strong> <strong>beer</strong>"

    }
}
